|
1
|
|
View Code Duplication |
"use strict"; |
|
2
|
|
|
|
|
3
|
|
|
app.controller('install03Controller', ['$scope', '$q', '$http', '$interval', '$rootScope', '$stateParams', function ($scope, $q, $http, $interval, $rootScope, $stateParams) { |
|
4
|
|
|
$(".release_info").hide(); |
|
5
|
|
|
|
|
6
|
|
|
$scope.releaseID = $stateParams.releaseID; |
|
7
|
|
|
|
|
8
|
|
|
$scope.mergeContent = function(){ |
|
9
|
|
|
if($scope.latestVersion != null){ |
|
10
|
|
|
var latestRelease = $scope.latestVersion; |
|
11
|
|
|
var tag_name = latestRelease.tag_name; |
|
12
|
|
|
var releaseZipDownloadURL = latestRelease.zipball_url; |
|
13
|
|
|
var releaseTarDownloadURL = latestRelease.tarball_url; |
|
14
|
|
|
|
|
15
|
|
|
$("#latest_release_zip").text(tag_name).parent("a").attr("href", releaseZipDownloadURL); |
|
16
|
|
|
$("#latest_release_tar").text(tag_name).parent("a").attr("href", releaseTarDownloadURL); |
|
17
|
|
|
|
|
18
|
|
|
$(".loading_info").hide(); |
|
19
|
|
|
|
|
20
|
|
|
// convert github release body content from Markdown to HTML |
|
21
|
|
|
var converter = new showdown.Converter(); |
|
22
|
|
|
//converter.setOption('backslashEscapesHTMLTags', 'true'); |
|
23
|
|
|
var markdown = latestRelease.body; |
|
24
|
|
|
|
|
25
|
|
|
/* |
|
26
|
|
|
// replace \< to <, \> to > |
|
27
|
|
|
var findStartTag = "\<"; |
|
28
|
|
|
var regularExpressStart = new RegExp(findStartTag, 'g'); |
|
29
|
|
|
var findEndTag = "\>"; |
|
30
|
|
|
var regularExpressEnd = new RegExp(findEndTag, 'g'); |
|
31
|
|
|
markdown = markdown.replace(regularExpressStart, '<'); |
|
32
|
|
|
markdown = markdown.replace(regularExpressEnd, '>'); |
|
33
|
|
|
*/ |
|
34
|
|
|
|
|
35
|
|
|
// remove all Backslash |
|
36
|
|
|
// 92 is Backslash |
|
37
|
|
|
var findBackslash = String.fromCharCode(92)+String.fromCharCode(92); |
|
38
|
|
|
var regularExpressBackslash = new RegExp(findBackslash, 'g'); |
|
39
|
|
|
markdown = markdown.replace(regularExpressBackslash, ''); |
|
40
|
|
|
|
|
41
|
|
|
// encode to html entities |
|
42
|
|
|
// https://stackoverflow.com/questions/18749591/encode-html-entities-in-javascript |
|
43
|
|
|
var encodedStr = markdown.replace(/[\u00A0-\u9999<>\&]/gim, function(i) { |
|
44
|
|
|
return '&#'+i.charCodeAt(0)+';'; |
|
45
|
|
|
}); |
|
46
|
|
|
|
|
47
|
|
|
var html = converter.makeHtml(encodedStr); |
|
48
|
|
|
|
|
49
|
|
|
latestRelease.html = html; |
|
50
|
|
|
|
|
51
|
|
|
/* |
|
52
|
|
|
console.dir(latestRelease) |
|
53
|
|
|
console.dir(converter) |
|
54
|
|
|
console.dir(markdown) |
|
55
|
|
|
console.dir(encodedStr) |
|
56
|
|
|
console.dir(html) |
|
57
|
|
|
console.dir(latestRelease) |
|
58
|
|
|
*/ |
|
59
|
|
|
|
|
60
|
|
|
$(".release_info").show(); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
$scope.get_information = function(){ |
|
65
|
|
|
$scope.initial_variable(); |
|
66
|
|
|
|
|
67
|
|
|
var getReleaseInfoResule = $scope.get_github_release_info($scope.releaseID); |
|
68
|
|
|
getReleaseInfoResule.then(function(infoObjList) { |
|
69
|
|
|
if(infoObjList.length > 0){ |
|
70
|
|
|
$scope.latestVersion = infoObjList[0]; |
|
71
|
|
|
} |
|
72
|
|
|
}, function(reason) { |
|
73
|
|
|
}); |
|
74
|
|
|
|
|
75
|
|
|
$q.all([getReleaseInfoResule]).then(function() { |
|
76
|
|
|
$scope.mergeContent(); |
|
77
|
|
|
}); |
|
78
|
|
|
} |
|
79
|
|
|
$scope.get_github_release_info = function(releaseID){ |
|
80
|
|
|
var arrayList = []; |
|
81
|
|
|
|
|
82
|
|
|
var promise = $q(function(resolve, reject) { |
|
83
|
|
|
var array = {text:"commits", amt:"10101", options}; |
|
|
|
|
|
|
84
|
|
|
|
|
85
|
|
|
$http({ |
|
86
|
|
|
method : "GET", |
|
87
|
|
|
//url : "https://api.github.com/repos/Otaku-Projects/AngularJS-CRUD-PHP/releases/"+releaseID |
|
88
|
|
|
url : "https://api.github.com/repositories/27926807/releases/"+releaseID |
|
89
|
|
|
}).then(function mySuccess(response) { |
|
90
|
|
|
var returnData = response.data; |
|
91
|
|
|
var totalReleasesCount = 0; |
|
|
|
|
|
|
92
|
|
|
/* |
|
93
|
|
|
returnData.forEach(function(releasesObj){ |
|
94
|
|
|
arrayList.push(releasesObj); |
|
95
|
|
|
}); |
|
96
|
|
|
*/ |
|
97
|
|
|
arrayList.push(returnData); |
|
98
|
|
|
|
|
99
|
|
|
resolve(arrayList); |
|
100
|
|
|
}, function myError(response) { |
|
101
|
|
|
reject(new Error('get project release info error')); |
|
102
|
|
|
}); |
|
103
|
|
|
|
|
104
|
|
|
}); |
|
105
|
|
|
|
|
106
|
|
|
return promise; |
|
107
|
|
|
} |
|
108
|
|
|
$scope.initial_variable = function(){ |
|
109
|
|
|
$scope.latestVersion = null; |
|
110
|
|
|
} |
|
111
|
|
|
function start_milestones(stackObjectList){ |
|
|
|
|
|
|
112
|
|
|
$("#milestones").html(""); |
|
113
|
|
|
|
|
114
|
|
|
var infoObj = stackObjectList.shift(); |
|
115
|
|
|
var elementContent = infoObj.text; |
|
116
|
|
|
var countUpAmt = infoObj.amt; |
|
117
|
|
|
var options = infoObj.options; |
|
118
|
|
|
$("#milestones").html("<div class='animated'>"+elementContent+"</div>"); |
|
119
|
|
|
$("#milestones div").addClass("fadeInUp"); |
|
120
|
|
|
|
|
121
|
|
|
if(!$scope.countUp){ |
|
122
|
|
|
$scope.countUp = new CountUp("count_up_amt", 0, options); |
|
123
|
|
|
$scope.countUp.start(); |
|
124
|
|
|
$("#count_up_amt").hide(); |
|
125
|
|
|
} |
|
126
|
|
|
$("#count_up_amt").show(); |
|
127
|
|
|
$scope.countUp.update(countUpAmt); |
|
128
|
|
|
|
|
129
|
|
|
stackObjectList.push(infoObj); |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
$scope.get_information(); |
|
133
|
|
|
}]); |